package com.woorigil.social.domain.category;

import org.apache.commons.lang.StringUtils;
import org.springframework.validation.Errors;
import org.springframework.validation.Validator;

public class CategoryValidator implements Validator {

	@SuppressWarnings("rawtypes")
	public boolean supports(Class clazz) {
		return Category.class.equals(clazz);
	}

	public void validate(Object obj, Errors e) {
//		ValidationUtils.rejectIfEmpty(e, "name", "nameEmpty");
		Category category = (Category) obj;
		if (StringUtils.isBlank(category.getName())) {
			e.rejectValue("name", "blank");
		} 
	}
}
